import BaseAction from "../../base/BaseAction";
import {Message} from "../../biz/Components";

export default class Action extends BaseAction {

    constructor(page) {
        super(page, "email");
    }

    // 配置 - 列表
    getSettingList(callback) {
        super.aardioCall("getSettingList").then(rsp => {
            let list = JSON.parse(rsp);
            if(callback){
                callback(list);
                return ;
            }
            list = list.map(name => {
                return {name}
            });
            this.setState({list});
        });
    }

    // 配置 - 获取
    getSetting(name, callback) {
        super.aardioCall("getSetting", name).then(rsp => {
            let vo = JSON.parse(rsp);
            vo.name = name;
            callback(vo);
        });
    }

    // 配置 - 保存
    saveSetting(vo) {
        super.aardioCall("saveSetting",vo).then(rsp=>{
            this.getSettingList();
            this.setState({detailStatus:""})

            Message.success("保存成功")
        });
    }

    // 配置 - 删除
    deleteSetting(name) {
        super.aardioCall("deleteSetting",name).then(rsp=>{
            this.getSettingList();
            this.setState({detailStatus:""})
            Message.success("删除成功")
        });
    }

    doStart(vo){
        super.aardioCall("start",vo);
    }
    doStop(){
        super.aardioCall("stop");
    }

}